package test;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

public class GetProcess{
	public static void main(String[] args) {
		
		String process = "QQ.exe";
		System.out.println(new GetProcess().getProcess(process));
	}
	
	
	boolean getProcess(String process){
		boolean flag=false;
		try{
			Process p = Runtime.getRuntime().exec( "cmd /c tasklist ");
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			InputStream os = p.getInputStream();
			byte b[] = new byte[256];
			while(os.read(b)> 0)
			baos.write(b);
			String s = baos.toString();
			if(s.indexOf(process)>=0){
				flag=true;
			}
			else{
			flag=false;
			}
		}catch(java.io.IOException ioe){
			ioe.printStackTrace();
		}
		return flag;
	}
}